package com.liao.ticket.controller;

import com.liao.ticket.service.AirportService;
import com.liao.ticket.vo.Result;
import com.liao.ticket.vo.params.AirportParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * *管理员使用*
 * 接口测试成功
 * 10.13 22:33  --
 * 1.0.0
 */
@RestController
@RequestMapping("airport")
public class AirportUpdateController {
    @Autowired
    private AirportService airportService;

    // 添加 机场
    @PostMapping("add")
    public Result addAirport(@RequestBody AirportParams airportParams) {
        return airportService.addOne(airportParams);
    }

    // 通过 机场id 修改 机场信息
    @PostMapping("update")
    public Result updateAirportById(@RequestBody AirportParams airportParams) {
        return airportService.updateOneById(airportParams);
    }

    // 通过 地点id 修改 地点
    @PostMapping("update/place")
    public Result updateAirportPlaceByPid(@RequestBody AirportParams airportParams) {
        return airportService.updateListPlaceNameByPid(airportParams);
    }

    // 通过 机场id 删除 机场
    @GetMapping("delete/{id}")
    public Result deleteAirportById(@PathVariable Long id) {
        return airportService.deleteOneById(id);
    }

    // 通过 地点id 删除 机场
    @GetMapping("delete/list/{id}")
    public Result deleteAirportListByPid(@PathVariable Integer id) {
        return airportService.deleteListByPid(id);
    }
}
